package com.digital.smartgrow.service.datacenter.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.digital.smartgrow.dao.datacenter.LearnExperienceMapper;
import com.digital.smartgrow.dto.datacenter.LearnExperiencePageDTO;
import com.digital.smartgrow.entity.datacenter.LearnExperience;
import com.digital.smartgrow.service.datacenter.LearnExperienceService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 学历经历 服务实现类
 * </p>
 *
 * @author xiewb
 * @since 2022-04-04
 */
@Service
public class LearnExperienceServiceImpl extends ServiceImpl<LearnExperienceMapper, LearnExperience> implements LearnExperienceService {

    @Override
    public Object getListByPage(LearnExperiencePageDTO pageDTO) {
        Page<LearnExperience> page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());
        QueryWrapper<LearnExperience> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getFinishSchool()), "finishSchool", pageDTO.getFinishSchool());
        queryWrapper.eq(StringUtils.isNotBlank(pageDTO.getEducation()), "education", pageDTO.getEducation());
        queryWrapper.and(StringUtils.isNotBlank(pageDTO.getName()),
                y -> y.like("name", pageDTO.getName()).or()
                        .like("employeeId", pageDTO.getName()));
        return this.page(page, queryWrapper);
    }

    @Override
    public Object getInfo(Integer id) {
        return this.getById(id);
    }
}
